@inject('News', 'App\Http\Controllers\Root\NewsController')
<div id="example2_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
    <div class="row">
        <div class="col-sm-12">
            <table class="table table-hover table-bordered">
                <tbody>
                <tr>
                    <th>标题</th>
                    <th>类型</th>
                    <th>操作</th>
                </tr>
                @foreach($news as $new)
                    <tr>
                        <td><a href="{{ url('details',['id'=>$new->typeid ]) }}" target="_blank" class="no-pjax">{!! $new->title !!}</a></td>
                        <td>{!! $News->getCategoryName($new->typeid) !!}</td>
                        <td>

                            <div class='btn-group'>
                                <a href="{!! route('news.edit', [$new->id]) !!}" class='btn btn-default btn-xs'><i
                                            class="glyphicon glyphicon-edit"></i></a>
                                {!! Form::button('<i class="glyphicon glyphicon-trash"></i>', ['class' => 'btn btn-danger btn-xs fb-delete','data-id'=> $new->id]) !!}
                            </div>

                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    </div>


    <div class="row">
        <div class="col-sm-5">
            <div class="dataTables_info" id="example2_info" role="status" aria-live="polite">
                共{{ count($news) }}条记录
            </div>
        </div>

        <div class="col-sm-7">
            <div class="dataTables_paginate paging_simple_numbers">
                {{ $news->links() }}
            </div>
        </div>
    </div>

</div>

<script>
  $('.fb-delete').click(function () {
    var del_id = $(this).data('id');
    var _tr = $(this).closest('tr');

    $.ajax({
      type: 'get',
      url: '/root/news/destroy/' + del_id,
      success: function (response) {
        console.dir(response);
        if (response.success) {
          _tr.fadeOut(function () {
            $(this).remove();
          });
        }
        else {
          modals.error(response.message);
        }
      }
    })

  })
</script>





